home *** CD-ROM | disk | FTP | other *** search
- /* modheaders.rexx - Takes a mail file and modifies some */
- /* headers that TIA installation leaves wrong... */
- /* v0.00alpha 1-17-95 */
- /* v0.01alpha 1-18-95 ... Apparently works. :) */
- /* v1.00 1-18-95 ... "Release" version */
- /* v1.01beta 1-31-95 ... more reqtools, because it rules */
- /* v1.02 3-8-95 ... Strip those blank lines ... */
- /* Also won't ask for headers that */
- /* are already there ... */
-
- /* As for my previous script package(s), this distribution */
- /* is freeware ... All I ask is that you tell me about any */
- /* changes/upgrades you make to this so that I and the rest */
- /* of Amiga-land might benefit from them ... */
-
- /* This script has been thrown together, but seeing as it */
- /* works great, I haven't felt the need to optimize it ... */
-
- /* Environment variables: */
- /* DRMEDITOR = pathname of your editor */
- /* DRMTIA = YES if you're using TIA or wish the script to */
- /* substitute DRMREAL in From: headers ... */
- /* DRMREAL = Your real email address. Required if you */
- /* set DRMTIA = YES */
- /* NEWSEDITOR = "sys:rexxc/rx wherever:you/put/modhdr.rexx" */
-
- /* Initialize */
-
- call addlib("rexxreqtools.library",0,-30,0)
- options results
- lf = '0a'x
- cr = '0d'x
- colon='3a'x
- semicol='3b'x
- qmark='22'x
- fonttag=""
- aflags=""
- address command
-
- /* Intercept the filename */
-
- localfile = ARG(1)
-
- /* Open file and parse the important headers */
-
- dummy = open(mf,localfile,read)
-
- subject = ""
- replyto = ""
- newsgroups = "***"
- mto = "***"
-
- do until currline = ""
- currline = readln(mf)
- currll = length(currline)
- if left(currline,8)=="Subject:" then subject = right(currline,currll-9)
- if left(currline,11)=="Newsgroups:" then newsgroups = right(currline,currll-12)
- if left(currline,5)=="From:" then replyto = right(currline,currll-6)
- if left(currline,3)=="To:" then mto = right(currline,currll-4)
- end
- call close mf
-
- /* The following makes a temp file with just the message body. We don't */
- /* need no steenking headers ... */
-
- /* Modification for 1.02 - remove extra blanks ... */
-
- call open mf,localfile,read
- call open tf,'t:msg.tmp',write
-
- firstline = 0
- eoheads = 0
- do until eof(mf)=1
- daline = readln(mf)
- if daline = "" then eoheads = 1
- if (eoheads=1)&(daline ~= "") then firstline=1
- if (eoheads = 1)&(firstline = 1) then call writeln tf,daline
- end
- call close mf
- call close tf
-
- /* Let's ask the user about the headers ... */
- /* If it's a news article, don't ask who it's to ... */
-
- ngroup = newsgroups
- whoto = mto
- msub = subject
-
- /* Modification for 1.02 - don't query if there's already a header. */
-
- if (newsgroups ~="***")&(strip(newsgroups)="") then do
- ngroup = getval(newsgroups," Where would you like to post this text? ")
- end
-
- if (newsgroups ="***")&(strip(mto)="") then do
- whoto = getval(mto," Who to mail this to? (user@host) ")
- end
-
- if strip(subject)="" then do
- msub = getval(subject," Enter a subject for this transmission: ")
- end
-
- if envar('DRMTIA')=="YES" then replyto = envar('DRMREAL')
- mfrom = replyto
-
- /* Uncomment the following if you want to be queried about your "From:" address each time */
- /* mfrom = getval(replyto," Where would you like to say this is from? (user@host) ") */
-
- /* We should probably edit the file without headers ... */
-
- TFileName = "T:msg.tmp"
-
- call open .dae,'t:modheaders.cmd',write
- call writeln .dae,envar('DRMEDITOR') TFileName
- call close .dae
-
- 'execute t:modheaders.cmd'
- 'delete 'localfile' QUIET'
-
- /* Change header options */
-
- hdflag = -1
-
- mcc = "<None>"
- mbcc = "<None>"
-
- do until hdflag = 0
-
- hdmsg = "Newsgroups :"||ngroup||lf||"Subject : "||msub||lf||"Reply-To : "mcc||lf||"Followup-To: "||mbcc
- hdbuttons = "_Newsgroups|_Subject|_Reply-To|_Followup-To|_Done!"
-
- if ngroup = "***" then do
- hdmsg = "To : "||whoto||lf||"Subject: "||msub||lf||"Cc : "mcc||lf||"Bcc : "||mbcc
- hdbuttons = "_To|_Subject|_Carbons|_Blind Carbons|_Done!"
- end
-
- hdflag = rtezrequest(hdmsg,hdbuttons,"Edit headers?","")
-
- select
-
- when hdflag = 1 then do
- mto = whoto
- if ngroup ~="***" then mto = ngroup
- mtxt = " Who to mail this to? (user@host) "
- if ngroup ~="***" then mtxt = " Where would you like to post this? "
- whoto = getval(mto,mtxt)
- if ngroup ~="***" then ngroup = whoto
- end
-
- when hdflag = 2 then do
- subject = msub
- msub = getval(subject," Enter a subject for this transmission: ")
- end
-
- when hdflag = 3 then do
- omcc = mcc
- mtxt = " Send carbon copies of this mail to? (user@host) "
- if ngroup ~="***" then mtxt = " Send replies to this news posting to? (user@host) "
- mcc = getval(omcc,mtxt)
- end
-
- when hdflag = 4 then do
- ombcc = mbcc
- mtxt = " Send blind carbon copies of this mail to? (user@host) "
- if ngroup ~="***" then mtxt = " Send followups to this news posting to? (user@host) "
- mbcc = getval(ombcc,mtxt)
- end
-
- otherwise
- end
- end
-
- /* Now that we've edited this file we should put together a message with */
- /* headers */
-
- call open hdr,"T:temp.hdr",write
-
- if ngroup = "***" then do
- call writeln hdr, 'To:' whoto
- end
-
- if ngroup ~= "***" then do
- call writeln hdr, 'Newsgroups:' ngroup
- end
-
- call writeln hdr, 'From:' mfrom
- call writeln hdr, 'Subject:' msub
-
- select
- when ngroup = "***" then do
- if mcc ~= "<None>" then call writeln hdr, 'Cc:' mcc
- if mbcc ~= "<None>" then call writeln hdr, 'Bcc:' mbcc
- end
- otherwise do
- if mcc ~= "<None>" then call writeln hdr, 'Reply-To:' mcc
- if mbcc ~= "<None>" then call writeln hdr, 'Followup-To:' mbcc
- end
- end
- call writeln hdr,""
-
- call close hdr
- 'join T:temp.hdr T:msg.tmp AS 'localfile
-
- /* Diagnostic line follows... */
- /* 'most 'localfile */
-
- /* Return control to the caller ... */
-
- exit
-
- /* Useful subprograms follow ... */
-
- getval: procedure
- parse arg defsub,msg
- mailsub = rtgetstring(defsub,msg,"ModHdr v1.02 by Rick Taylor","Ok","")
- if mailsub = "" then mailsub = defsub
- if mailsub = "" then mailsub = "<None>"
- return mailsub
-
- diagnostic: procedure
- parse arg showit
- msg = "Value = "||showit
- cf=rtezrequest(msg,"OK","Diagnostic","")
- return cf
-
- envar: procedure
- arg evname
- epath = "ENV:"||evname
- evalue = ""
- if exists(epath) then do
- call open .envar,epath,read
- evalue = readln(.envar)
- call close .envar
- end
- return evalue
-
-